package com.resolution.dietaryassessment.view.tcm.fragment;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;

import com.example.rxbus.RxBus;
import com.example.rxbus.bean.MsgEvent;
import com.resolution.dietaryassessment.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;


/**
 * @author By Resolusion
 * @Title: 体质简介
 * @Date: 2020/3/31
 * @Time: 15:25
 * @email res01ution@foxmail.com
 */
public class ConstitutionIntroductionFrag extends Fragment {
    private final static String TITLE_ONE = "平和质";
    private final static String TITLE_TWO = "气虚质";
    private final static String TITLE_THREE = "阳虚质";
    private final static String TITLE_FOUR = "阴虚质";
    private final static String TITLE_FIVE = "痰湿质";
    private final static String TITLE_SIX = "湿热质";
    private final static String TITLE_SEVEN = "血瘀质";
    private final static String TITLE_EIGHT = "气郁质";
    private final static String TITLE_NINE = "特禀质";

    @BindView(R.id.title1)
    TextView title1;
    @BindView(R.id.title0)
    TextView title0;
    @BindView(R.id.features_tx)
    TextView featuresTx;
    @BindView(R.id.reason_tx)
    TextView reasonTx;
    @BindView(R.id.body_features_tx)
    TextView bodyFeaturesTx;
    @BindView(R.id.psychology_tx)
    TextView psychologyTx;
    @BindView(R.id.inclination_tx)
    TextView inclinationTx;
    @BindView(R.id.performance_tx)
    TextView performanceTx;
    @BindView(R.id.crowd_tx)
    TextView crowdTx;
    @BindView(R.id.outside_tx)
    TextView outsideTx;
    @BindView(R.id.ysjy_tx)
    TextView ysjyTx;
    @BindView(R.id.jsty_tx)
    TextView jstyTx;
    @BindView(R.id.yszb_tx)
    TextView yszbTx;
    @BindView(R.id.ydcf_tx)
    TextView ydcfTx;
    @BindView(R.id.ywys_tx)
    TextView ywysTx;
    @BindView(R.id.tips_tx)
    TextView tipsTx;

    private Unbinder unbinder;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @SuppressLint("CheckResult")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_constitution_introduction, container, false);
        unbinder = ButterKnife.bind(this, view);
        RxBus.getInstance().toObservable(getActivity(), MsgEvent.class, Lifecycle.Event.ON_ANY).subscribe(msgEvent -> {
            title0.setText(msgEvent.getMsg());
            title1.setText(msgEvent.getMsg());
            switch (msgEvent.getMsg()) {
                case TITLE_ONE:
                   setPeaceTX();
                   break;
                case TITLE_TWO:
                    setQiDeficiencyTx();
                    break;
                case TITLE_THREE:
                    setYangDeficiencyTx();
                    break;
                case TITLE_FOUR:
                    setYinDeficiencyTx();
                    break;
                case TITLE_FIVE:
                    setPhlegmDampTx();
                    break;
                case TITLE_SIX:
                    setDampHeatTx();
                    break;
                case TITLE_SEVEN:
                    setBloodStasisTx();
                    break;
                case TITLE_EIGHT:
                    setQiDepressionTx();
                    break;
                case TITLE_NINE:
                    setSpecialGiftTx();
            }
        });
        return view;
    }

    /**
     * 平和质
     */
    private void setPeaceTX() {
        featuresTx.setText(getResources().getString(R.string.pe_features));
        reasonTx.setText(getResources().getString(R.string.pe_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.pe_bd_features));
        psychologyTx.setText(getResources().getString(R.string.pe_pcg));
        inclinationTx.setText(getResources().getString(R.string.pe_inclination));
        performanceTx.setText(getResources().getString(R.string.pe_cp));
        crowdTx.setText(getResources().getString(R.string.pe_cc));
        outsideTx.setText(getResources().getString(R.string.pe_ab));
        ysjyTx.setText(getResources().getString(R.string.pe_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.pe_jsty));
        yszbTx.setText(getResources().getString(R.string.pe_yszb));
        ydcfTx.setText(getResources().getString(R.string.pe_ydcf));
        ywysTx.setText(getResources().getString(R.string.pe_ywys));
        tipsTx.setText(getResources().getString(R.string.pe_tip));
    }

    /**
     * 气虚质
     */
    private void setQiDeficiencyTx() {
        featuresTx.setText(getResources().getString(R.string.qdf_features));
        reasonTx.setText(getResources().getString(R.string.qdf_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.qdf_bd_features));
        psychologyTx.setText(getResources().getString(R.string.qdf_pcg));
        inclinationTx.setText(getResources().getString(R.string.qdf_inclination));
        performanceTx.setText(getResources().getString(R.string.qdf_cp));
        crowdTx.setText(getResources().getString(R.string.qdf_cc));
        outsideTx.setText(getResources().getString(R.string.qdf_ab));
        ysjyTx.setText(getResources().getString(R.string.qdf_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.qdf_jsty));
        yszbTx.setText(getResources().getString(R.string.qdf_yszb));
        ydcfTx.setText(getResources().getString(R.string.qdf_ydcf));
        ywysTx.setText(getResources().getString(R.string.qdf_ywys));
        tipsTx.setText(getResources().getString(R.string.qdf_tip));
    }

    /**
     * 阳虚质
     */
    private void setYangDeficiencyTx() {
        featuresTx.setText(getResources().getString(R.string.ydf_features));
        reasonTx.setText(getResources().getString(R.string.ydf_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.ydf_bd_features));
        psychologyTx.setText(getResources().getString(R.string.ydf_pcg));
        inclinationTx.setText(getResources().getString(R.string.ydf_inclination));
        performanceTx.setText(getResources().getString(R.string.ydf_cp));
        crowdTx.setText(getResources().getString(R.string.ydf_cc));
        outsideTx.setText(getResources().getString(R.string.ydf_ab));
        ysjyTx.setText(getResources().getString(R.string.ydf_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.ydf_jsty));
        yszbTx.setText(getResources().getString(R.string.ydf_yszb));
        ydcfTx.setText(getResources().getString(R.string.ydf_ydcf));
        ywysTx.setText(getResources().getString(R.string.ydf_ywys));
        tipsTx.setText(getResources().getString(R.string.ydf_tip));
    }

    private void setYinDeficiencyTx() {
        featuresTx.setText(getResources().getString(R.string.yindf_features));
        reasonTx.setText(getResources().getString(R.string.yindf_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.yindf_bd_features));
        psychologyTx.setText(getResources().getString(R.string.yindf_pcg));
        inclinationTx.setText(getResources().getString(R.string.yindf_inclination));
        performanceTx.setText(getResources().getString(R.string.yindf_cp));
        crowdTx.setText(getResources().getString(R.string.yindf_cc));
        outsideTx.setText(getResources().getString(R.string.yindf_ab));
        ysjyTx.setText(getResources().getString(R.string.yindf_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.yindf_jsty));
        yszbTx.setText(getResources().getString(R.string.yindf_yszb));
        ydcfTx.setText(getResources().getString(R.string.yindf_ydcf));
        ywysTx.setText(getResources().getString(R.string.yindf_ywys));
        tipsTx.setText(getResources().getString(R.string.yindf_tip));
    }

    private void setPhlegmDampTx() {
        featuresTx.setText(getResources().getString(R.string.pd_features));
        reasonTx.setText(getResources().getString(R.string.pd_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.pd_bd_features));
        psychologyTx.setText(getResources().getString(R.string.pd_pcg));
        inclinationTx.setText(getResources().getString(R.string.pd_inclination));
        performanceTx.setText(getResources().getString(R.string.pd_cp));
        crowdTx.setText(getResources().getString(R.string.pd_cc));
        outsideTx.setText(getResources().getString(R.string.pd_ab));
        ysjyTx.setText(getResources().getString(R.string.pd_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.pd_jsty));
        yszbTx.setText(getResources().getString(R.string.pd_yszb));
        ydcfTx.setText(getResources().getString(R.string.pd_ydcf));
        ywysTx.setText(getResources().getString(R.string.pd_ywys));
        tipsTx.setText(getResources().getString(R.string.pd_tip));
    }

    private void setDampHeatTx() {
        featuresTx.setText(getResources().getString(R.string.dh_features));
        reasonTx.setText(getResources().getString(R.string.dh_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.dh_bd_features));
        psychologyTx.setText(getResources().getString(R.string.dh_pcg));
        inclinationTx.setText(getResources().getString(R.string.dh_inclination));
        performanceTx.setText(getResources().getString(R.string.dh_cp));
        crowdTx.setText(getResources().getString(R.string.dh_cc));
        outsideTx.setText(getResources().getString(R.string.dh_ab));
        ysjyTx.setText(getResources().getString(R.string.dh_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.dh_jsty));
        yszbTx.setText(getResources().getString(R.string.dh_yszb));
        ydcfTx.setText(getResources().getString(R.string.dh_ydcf));
        ywysTx.setText(getResources().getString(R.string.dh_ywys));
        tipsTx.setText(getResources().getString(R.string.dh_tip));
    }

    private void setBloodStasisTx() {
        featuresTx.setText(getResources().getString(R.string.bs_features));
        reasonTx.setText(getResources().getString(R.string.bs_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.bs_bd_features));
        psychologyTx.setText(getResources().getString(R.string.bs_pcg));
        inclinationTx.setText(getResources().getString(R.string.bs_inclination));
        performanceTx.setText(getResources().getString(R.string.bs_cp));
        crowdTx.setText(getResources().getString(R.string.bs_cc));
        outsideTx.setText(getResources().getString(R.string.bs_ab));
        ysjyTx.setText(getResources().getString(R.string.bc_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.bc_jsty));
        yszbTx.setText(getResources().getString(R.string.bc_yszb));
        ydcfTx.setText(getResources().getString(R.string.bc_ydcf));
        ywysTx.setText(getResources().getString(R.string.bc_ywys));
        tipsTx.setText(getResources().getString(R.string.bc_tip));
    }

    private void setQiDepressionTx() {
        featuresTx.setText(getResources().getString(R.string.qdp_features));
        reasonTx.setText(getResources().getString(R.string.qdp_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.qdp_bd_features));
        psychologyTx.setText(getResources().getString(R.string.qdp_pcg));
        inclinationTx.setText(getResources().getString(R.string.qdp_inclination));
        performanceTx.setText(getResources().getString(R.string.qdp_cp));
        crowdTx.setText(getResources().getString(R.string.qdp_cc));
        outsideTx.setText(getResources().getString(R.string.qdp_ab));
        ysjyTx.setText(getResources().getString(R.string.qdp_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.qdp_jsty));
        yszbTx.setText(getResources().getString(R.string.qdp_yszb));
        ydcfTx.setText(getResources().getString(R.string.qdp_ydcf));
        ywysTx.setText(getResources().getString(R.string.qdp_ywys));
        tipsTx.setText(getResources().getString(R.string.qdp_tip));
    }

    private void setSpecialGiftTx() {
        featuresTx.setText(getResources().getString(R.string.sg_features));
        reasonTx.setText(getResources().getString(R.string.sg_reason));
        bodyFeaturesTx.setText(getResources().getString(R.string.sg_bd_features));
        psychologyTx.setText(getResources().getString(R.string.sg_pcg));
        inclinationTx.setText(getResources().getString(R.string.sg_inclination));
        performanceTx.setText(getResources().getString(R.string.sg_cp));
        crowdTx.setText(getResources().getString(R.string.sg_cc));
        outsideTx.setText(getResources().getString(R.string.sg_ab));
        ysjyTx.setText(getResources().getString(R.string.sg_dietary_sg));
        jstyTx.setText(getResources().getString(R.string.sg_jsty));
        yszbTx.setText(getResources().getString(R.string.sg_yszb));
        ydcfTx.setText(getResources().getString(R.string.sg_ydcf));
        ywysTx.setText(getResources().getString(R.string.sg_ywys));
        tipsTx.setText(getResources().getString(R.string.sg_tip));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

}
